<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>店铺列表</title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="../css/mui.min.css" rel="stylesheet" />
    <link href="../phoneCss/commons.css" rel="stylesheet" />
    <link href="../phoneCss/confirmOrder.css" rel="stylesheet" />
    <style>
        body,.mui-content{
            background: #fff;
        }
        .address{
            border-bottom: 1px solid #f1f1f1;
            padding-bottom: 20px;
        }
    </style>
</head>
<body>
<!--
    作者：lwy
    时间：2017-11-10
    描述：店铺列表
-->
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">店铺列表</h1>
</header>

<div class="mui-content">
    <div class="addressBox mui-clearfix">
        <!--<div class="address_icon"><img src="../img/address_icon.png" alt="地址"></div>-->
        <!--<div class="address_info">-->
            <!--<div class="user_info">联系人<span class="name">名字</span><span class="phone"></span></div>-->
            <!--<div class="address_detail">详细地址</div>-->
        <!--</div>-->
    </div>
</div>


<script src="../js/mui.min.js"></script>
<script src="../js/jquery-1.10.1.min.js"></script>
<script>
    document.write("<s" + "cript type='text/javascript' src='../js/common.js?" + Math.random() + "'></scr" + "ipt>");
</script>
<script type="text/javascript">
    $(function () {
        $.ajax({
            url:'/ddmShopC/getPortalShopList.json',
            dataType:'json',
            data:{
                page:1,
                companyCode:getItem('companyCode'),
            },
            type:'post',
            success:function (data) {
                if(data.code==1){
                    for(var i=0;i<data.datas.length;i++){
                        $('<div class="address mui-clearfix" lnt="'+data.datas[i].longitudeAndLatitude+'" id="'+data.datas[i].id+'"><div class="address_icon"><img src="../phoneImg/address.png" alt="地址"></div>\n' +
                            '<div class="address_info">\n' +
                            '<div class="user_info">联系人<span class="name">'+data.datas[i].linkman+'</span><span class="phone">'+data.datas[i].contact+'</span></div>\n' +
                            '<div class="address_detail">'+data.datas[i].name+' '+data.datas[i].location+'</div>\n' +
                            '</div></div>').appendTo($('.addressBox'))
                    }
                    var address1 = $('.address:nth-child(1)');
                    addAddress(address1.find('.name').html(),address1.find('.phone').html(),address1.find('.address_detail').html(),address1.attr('lnt'),address1.attr('id'))

                    $('.address').click(function () {
                        var selThis = $(this);
                        addAddress(selThis.find('.name').html(),selThis.find('.phone').html(),selThis.find('.address_detail').html(),selThis.attr('lnt'),selThis.attr('id'))
//                        var shopAddress = {};
//                        shopAddress.name = selThis.find('.name').html();
//                        shopAddress.phone = selThis.find('.phone').html();
//                        shopAddress.detail = selThis.find('.address_detail').html();
//                        shopAddress.lnt = selThis.attr('lnt');
//                        setItem('shopAddress',JSON.stringify(shopAddress));
                        history.go(-2);
                    })

                    function addAddress(name,phone,detail,lnt,id) {
                        var shopAddress = {};
                        shopAddress.name = name;
                        shopAddress.phone = phone;
                        shopAddress.detail = detail;
                        shopAddress.lnt = lnt;
                        shopAddress.id = id;
                        setItem('shopAddress',JSON.stringify(shopAddress));
                    }

                }
                if(data.code==0){
                    mui.toast(data.msg);
                }
            }
        })
    })
</script>
</body>
</html>
